#coding=utf8

from base import TBase

class Increment(TBase):
    typename = 'increment'
    method = 'increment.'
    fields= ''
    def customer_permit (self, sessionkey, fields=''):
        self.method = 'increment.customer.permit'
        self.session = sessionkey
        return self.do()

    def customers_get (self, sessionkey, nick=''):
        self.method = 'increment.customers.get'
        if nick:
            self.setParams(nicks=nick)
        self.session = sessionkey
        return self.do()

    def trades_get(self, sessionkey, nick='', start='', end='', page_no=1, page_size=200):
        if start:
            self.setParams(start_modified=start)
        if end:
            self.setParams(end_modified=end)
        if nick:
            self.setParams(nick=nick)
        self.setParams(page_no=page_no)
        self.setParams(page_size=page_size)
        self.method = 'increment.trades.get'
        self.session = sessionkey
        return self.do()

    def items_get(self, sessionkey, nick='', start='', end='', page_no=1, page_size=200):
        if start:
            self.setParams(start_modified=start)
        if end:
            self.setParams(end_modified=end)
        if nick:
            self.setParams(nick=nick)
        self.setParams(page_no=page_no)
        self.setParams(page_size=page_size)
        self.method = 'increment.items.get'
        self.session = sessionkey
        return self.do()





if __name__  == '__main__':
    import time
    import json
    yesterday = time.localtime(time.time() - 86400)
    yesterday = time.strftime('%Y-%m-%d', yesterday)
    begin_time = yesterday+' 00:00:00'
    end_time = yesterday+' 23:59:59'
    a = Increment()
    #b = a.trades_get('61019263bdcac9df240e361cd207fe59fc10ab0b651cc4639636564', 'amiczhou', start=begin_time, end=end_time)
    b = a.items_get('61019263bdcac9df240e361cd207fe59fc10ab0b651cc4639636564') #, 'amiczhou', start=begin_time, end=end_time)
    json.dump(b, open('aaaaaaaaaaaaaaa.json', 'w'))


